<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>The MongoMaxKey class</title>

 </head>
 <body><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="class.mongominkey.html">MongoMinKey</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="class.mongotimestamp.html">MongoTimestamp</a></div>
 <div class="up"><a href="mongo.types.html">Types</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div><hr /><div id="class.mongomaxkey" class="reference">

 <h1 class="title">The MongoMaxKey class</h1>
 

 <div class="partintro"><p class="verinfo">(PECL mongo &gt;= 1.0.2)</p>


  <div class="section" id="mongomaxkey.intro">
   <h2 class="title">简介</h2>
   <p class="para">
    <strong class="classname">MongoMaxKey</strong> is a special type used by the database 
    that evaluates to greater than any other type.  Thus, if a query is sorted 
    by a given field in ascending order, any document with a 
    <strong class="classname">MongoMaxKey</strong> as its value will be returned last.
   </p>
   <p class="para">
    <strong class="classname">MongoMaxKey</strong> has no associated fields, methods, or
    constants.  It is merely the &quot;largest&quot; thing that can be inserted into the
    database.
   </p>
  </div>


  <div class="section" id="mongomaxkey.synopsis">
   <h2 class="title">类摘要</h2>


   <div class="classsynopsis">
    <div class="ooclass"></div>


    <div class="classsynopsisinfo">
     <span class="ooclass">
      <strong class="classname">MongoMaxKey</strong>
     </span>
     {</div>

   }</div>


  </div>

  <div class="section" id="mongomaxkey.example">
   <h2 class="title">Using <strong class="classname">MongoMaxKey</strong> as a value</h2>
   <div class="example-contents">
<div class="phpcode"><code><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />$collection</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">insert</span><span style="color: #007700">(array(</span><span style="color: #DD0000">"task"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"dishes"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"do&nbsp;by"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;new&nbsp;</span><span style="color: #0000BB">MongoMaxKey</span><span style="color: #007700">));<br /></span><span style="color: #0000BB">$collection</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">insert</span><span style="color: #007700">(array(</span><span style="color: #DD0000">"task"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #DD0000">"staff&nbsp;meeting"</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">"do&nbsp;by"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;new&nbsp;</span><span style="color: #0000BB">MongoDate</span><span style="color: #007700">(</span><span style="color: #0000BB">strtotime</span><span style="color: #007700">(</span><span style="color: #DD0000">"+4&nbsp;days"</span><span style="color: #007700">))));<br /><br /></span><span style="color: #0000BB">$cursor&nbsp;</span><span style="color: #007700">=&nbsp;</span><span style="color: #0000BB">$collection</span><span style="color: #007700">-&gt;</span><span style="color: #0000BB">find</span><span style="color: #007700">()-&gt;</span><span style="color: #0000BB">sort</span><span style="color: #007700">(array(</span><span style="color: #DD0000">"do&nbsp;by"&nbsp;</span><span style="color: #007700">=&gt;&nbsp;</span><span style="color: #0000BB">1</span><span style="color: #007700">));<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</code></div>
   </div>

   <p class="para">
    The cursor will contain the staff meeting document, then the dishes 
    document. The dishes document will always be returned last, regardless of 
    what else is added to the collection (unless other documents are added with
    <strong class="classname">MongoMaxKey</strong> in the &quot;do by&quot; field).
   </p>
  </div>
 </div>

</div>
<hr /><div class="manualnavbar" style="text-align: center;">
 <div class="prev" style="text-align: left; float: left;"><a href="class.mongominkey.html">MongoMinKey</a></div>
 <div class="next" style="text-align: right; float: right;"><a href="class.mongotimestamp.html">MongoTimestamp</a></div>
 <div class="up"><a href="mongo.types.html">Types</a></div>
 <div class="home"><a href="index.html">PHP Manual</a></div>
</div></body></html>
